home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
REMLIFE.ARJ
/
REMTAB.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1989-10-24
|
3KB
|
131 lines
{$B+} {Boolean complete evaluation on}
PROGRAM REMTAB;
{ Removes tabs from a file and replaces then with 5 blanks }
Uses
Crt, {Unit found in TURBO.TPL}
Dos;
TYPE
FILETYPE = TEXT;
FILENAME = STRING[255]; { full path name }
VAR
INFILE, BACKUP, OUTFILE : FILETYPE;
INNAME, BACKNAME, OUTNAME : FILENAME;
BFILEVAR : FILE;
Procedure Init;
Procedure MakeBackup;
VAR
I,J : INTEGER;
Ch : Char;
DirInfo : SearchRec;
BEGIN
BackName := InName;
I := 1;
J := length(InName);
While (I <> J) AND (BackName[I] <> '.') do
I := succ(I);
I := Succ(I);
BackName[I] := 'B'; BackName[I+1] := 'A'; BackName[I+2] := 'K';
If I > J
THEN BackName[0] := CHR(J + 3)
ELSE BackName[0] := CHR(J-(J-I+1) + 3);
WriteLn;
FindFirst(InName,AnyFile,DirInfo); { Look At this }
If DosError <> 0 { Then -- oops, input file non existent }
Then
begin
Write('Input file does not exist...exiting.');
Halt(1);
end;
Write('Backing Up File....');
Assign(BfileVar,BackName); { Do this to....}
FindFirst(BackName,AnyFile,DirInfo); { Check Existence of backup }
If DosError = 0 { Then the file was found -- Delete the old backup }
Then Erase(BfileVar);
Assign(BfileVar,InName); { assign }
Rename(BFILEVAR,BackName);
WriteLn('DONE.');
END;
BEGIN
WriteLn('REMTAB -- Removes Tab Characters from Printable file');
If (ParamCount = 0)
Then
begin
Write('Pathname of file :: ');
ReadLn(InName); { Get the file name }
end
else
begin
InName := ParamStr(1);
WriteLn(InName,' is the file to process.');
end;
If InName = ''
Then
begin
WriteLn('No File Name Specified... Exiting.');
Halt(1);
end;
MakeBackUp;
END;
PROCEDURE RUN;
VAR
CH : Char;
Place : Integer;
BEGIN
Place := 1;
OutName := InName;
InName := BackName;
Assign (Infile,InName);
Reset(InFile);
Assign (Outfile,OutName);
ReWrite(OutFile);
Write('Converting......');
While NOT Eof(InFile) DO
BEGIN
Read(Infile,CH); { Get a Char }
If CH = Chr(9) { Tab? }
Then Begin
IF ((Place MOD 8) = 0) THEN
Begin
Write(OutFile,' ');
Place := Succ(Place);
End;
IF ((Place MOD 8) <> 0) THEN
Repeat
Write(OutFile,' ');
Place := Succ(Place);
Until ((Place MOD 8) = 0);
End
Else If Ch = Chr(13)
Then Begin
Place := -1;
Write(OutFile,Ch);
End
Else Begin
Write(OutFile,Ch);
Place := Succ(Place);
End;
End;
Close(InFile);
Close(OutFile);
WriteLn('DONE!');
END;
BEGIN { MAIN }
TextColor(LightGray);
Init;
Run;
END.